//! @Author: DengLibin
//! @Date: Create in 2025-03-19 11:37:28
//! @Description:


use my_trait::MustHaveTableName;
use sqlx::{MySql, Pool};

use crate::{
    entity::article::Article,
    sys::global::{to_global_result, GlobalResult},
};

/// @Author: DengLibin
/// @Date: Create in 2025-03-19 16:22:28
/// @Description:
pub async fn update_content(id: i64, content: &str, pool: &Pool<MySql>) -> GlobalResult<u64> {
    let sql = format!("UPDATE {} set content=? WHERE id=?", Article::table_name());
    let result = sqlx::query(&sql).bind(content).bind(id).execute(pool).await;
    let r = to_global_result(result)?;
    Ok(r.rows_affected())
}
 /// @Author: DengLibin
 /// @Date: Create in 2025-03-21 10:43:12
 /// @Description: 
pub async fn update_orgs(id: i64, orgs: &str, pool: &Pool<MySql>) -> GlobalResult<u64> {
    let sql = format!("UPDATE {} set orgs=? WHERE id=?", Article::table_name());
    let result = sqlx::query(&sql).bind(orgs).bind(id).execute(pool).await;
    let r = to_global_result(result)?;
    Ok(r.rows_affected())
}
